package com.msun.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.msun.dao.QuestionnaireServiceDao;
import com.msun.entity.PageResult;
import com.msun.entity.QueryPageBean;
import com.msun.pojo.Plan;
import com.msun.pojo.Questionnaire;
import com.msun.service.OrderListService;
import com.msun.service.QuestionnaireService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service(interfaceClass = QuestionnaireService.class)
@Transactional
public class QuestionnaireServiceImpl implements QuestionnaireService {
    @Autowired
    private QuestionnaireServiceDao questionnaireServiceDao;
    @Override
    public PageResult pageQuery(QueryPageBean queryPageBean) {
        Integer currentPage = queryPageBean.getCurrentPage();
        Integer pageSize = queryPageBean.getPageSize();
        String queryString = queryPageBean.getQueryString();//查询条件
        //完成分页查询，基于mybatis框架提供的分页助手插件完成
        PageHelper.startPage(currentPage,pageSize);
        //select * from t_checkitem limit 0,10
        Page<Questionnaire> page = questionnaireServiceDao.selectByCondition(queryString);
        long total = page.getTotal();
        List<Questionnaire> rows = page.getResult();
        return new PageResult(total,rows);
    }

    @Override
    public void del(Integer id) {
        questionnaireServiceDao.del(id);
    }

    @Override
    public void edit(Questionnaire questionnaire) {
        questionnaireServiceDao.edit(questionnaire);
    }

    @Override
    public Questionnaire findByName(String s) {
        return questionnaireServiceDao.findByName(s);
    }

    @Override
    public void add(Questionnaire questionnaire) {
        questionnaireServiceDao.add(questionnaire);
    }
}
